<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
</head>
<body>
<div>
    <div>用户名：<input id="username"/></div>
    <div>密码：<input id="password"/></div>
    <div><button id="btnLogin">登录</button></div>
</div>

</body>
<script src="../../lib/jquery-3.6.0.js"></script>
<script>

     $('#btnLogin').click(function () {
         var user = {
             username:$('#username').val(),
             password:$('#password').val()
         }

         user = JSON.stringify(user);//json的序列化---把json对象变成字符串
         localStorage.setItem("user",user);//


     })


</script>
</html>